#pragma once
#include<iostream>
#include<pthread.h>
#include"Mutex.hpp"
using namespace MutexModel;

namespace CondModel{
    class Cond{
        public:
        Cond(){
            pthread_cond_init(&cond,nullptr);
        }
        void Wait(Mutex&mutex){
            int n = pthread_cond_wait(&cond,mutex.Get());
            (void)n;
        }
        void Singal(){
            int n = pthread_cond_signal(&cond);
            (void)n;
        }
        void Broadcast(){
            int n = pthread_cond_broadcast(&cond);
            (void)n;
        }
        
        ~Cond(){
            //避免编译器报错，变量未使用
            int n = pthread_cond_destroy(&cond);
            (void)n;
        }

        private:
        pthread_cond_t cond;
    };

}